package com.sunline.vuedemo.controller;


import com.sunline.vuedemo.bean.SysUser;
import com.sunline.vuedemo.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * (SysUser)表控制层
 *
 * @author makejava
 * @since 2020-12-22 14:46:19
 */
@RestController
@RequestMapping("sysUser")
@CrossOrigin
@Api("用户表测试")
public class SysUserController {
    /**
     * 服务对象
     */
    @Resource
    private SysUserService sysUserService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    public SysUser selectOne(String id) {

        return this.sysUserService.queryById(id);
    }
    /**
     * 查询全部数据
     *
     *
     * @return 单条数据
     */
    @GetMapping("selectAll")
    @ApiOperation(value = "查询全部数据")
    public List<SysUser> selectAll(int currentPage) {

        return this.sysUserService.queryAll(currentPage);
    }
    /**
     * 新增数据
     *
     * @param sysUser 实例对象
     * @return 实例对象
     */
    @PostMapping("insert")
    @ApiOperation(value = "新增数据")
    public SysUser insert(SysUser sysUser) {
        return this.sysUserService.insert(sysUser);
    }
    /**
     * 修改数据
     *
     * @param sysUser 实例对象
     * @return 实例对象
     */
    @PostMapping("update")
    @ApiOperation(value = "修改数据")
     public SysUser update(SysUser sysUser){
        return this.sysUserService.update(sysUser);
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @PostMapping("delet")
    @ApiOperation(value = "过主键删除数据")
    public boolean deleteById(String userId) {

        return this.sysUserService.deleteById(userId);
    }



}